<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ attribute name="link" required="true"%>

<c:if test="${pages gt 1}">
  <c:set var="order" value="" />
  <c:if test="${param.o gt 0}">
    <c:set var="order" value="&o=${param.o}" />
  </c:if>
  <tr class="p c">
    <td colspan=7>
      <c:forEach begin="1" end="${pages}" step="1" var="page">
        <c:choose>
          <c:when test="${page eq 1 and empty param.p}">
            <span class="page" id="active"><c:out value="${page}" /></span>
          </c:when>
          <c:when test="${page eq param.p}">
            <span class="page" id="active"><c:out value="${page}" /></span>
          </c:when>
          <c:otherwise>
            <c:url value="${link}" var="url">
              <c:param name="p" value="${page}" />
            </c:url>
            <a href="${url}${order}"><span class="page"><c:out value="${page}" /></span></a>
          </c:otherwise>
        </c:choose>
      </c:forEach></td>
  </tr>
</c:if>
